//
//  HBFactory.swift
//  sinaWeibo
//
//  Created by Beans on 16/7/5.
//  Copyright © 2016年 iceWorks. All rights reserved.
//

import UIKit

class HBFactory {
    /*
    工厂设计模式: 由父类定义协议, 子类去实现
    */

    class func getButton(title: String, titleColor: UIColor, font: CGFloat, image: String, bgImage: String, tag: Int, target: AnyObject, method: String) -> UIButton {
        let button = UIButton(type: .Custom)

        button.setTitle(title, forState: .Normal)
        button.setTitleColor(titleColor, forState: .Normal)
        button.titleLabel?.font = UIFont.systemFontOfSize(font)
        button.setImage(UIImage(named: image), forState: .Normal)
        button.setBackgroundImage(UIImage(named: bgImage), forState: .Normal)
        button.tag = tag

        // target千万不要写self
        button.addTarget(target, action: Selector(method), forControlEvents: .TouchUpInside)

        return button
    }
}
